
package jfc.ui;

import java.awt.Dimension;
import java.net.URL;
import javax.swing.ImageIcon;
import jfc.core.Suit;

/**
 *  @author Yann Le Gall
 *  ylegall@gmail.com
 *  Oct 25, 2009 8:57:54 PM
 */
public class ImageManager
{
    private ImageIcon[] suits;
    private ImageIcon card;
    private static final ImageManager instance;
    private final Dimension dimension;

    static {
        instance = new ImageManager();
    }

    public static ImageManager getInstance() {
        return instance;
    }

    private ImageManager()
    {
        suits = new ImageIcon[4];
        int i=0;
        URL url;

        String root = "/jfc/resources/";

        for(Suit s: Suit.values()) {
            url = ImageManager.class.getResource(root+s.name() + ".png");
            suits[i++] = new ImageIcon(url);
        }

        url = ImageManager.class.getResource(root+"card.png");
        card = new ImageIcon(url);
        dimension = new Dimension(card.getIconWidth(), card.getIconHeight());
    }

    public ImageIcon getCardImage() {
        return card;
    }

    public ImageIcon getImage(Suit suit) {
        return suits[suit.ordinal()];
    }

    public Dimension getCardSize() {return dimension;}
}
